import numpy as np # linear alegebra
import pandas as pd # data processing ,csv i/o (eg.- pd.read_csv)
import seaborn as sns # advance visutalisation
sns.set(style='whitegrid')
import matplotlib.pyplot as plt # visualisation
from collections import Counter
%matplotlib inline
import os
os.getcwd()
'C:\\Users\\bibhu'
import warnings # it will ignore the warnings and give output
warnings.filterwarnings('ignore')
fifa19 = pd.read_csv(r"C:\Users\bibhu\OneDrive\Desktop\18 aug rsume proj and heart risk analysis\18th_resume project\18th_resume project\Seaborn\FIFA.csv")
fifa19
| Unnamed: 0 | ID | Name | Age | Photo | Nationality | Flag | Overall | Potential | Club | ... | Composure | Marking | StandingTackle | SlidingTackle | GKDiving | GKHandling | GKKicking | GKPositioning | GKReflexes | Release Clause | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 0 | 158023 | L. Messi | 31 | https://cdn.sofifa.org/players/4/19/158023.png | Argentina | https://cdn.sofifa.org/flags/52.png | 94 | 94 | FC Barcelona | ... | 96.0 | 33.0 | 28.0 | 26.0 | 6.0 | 11.0 | 15.0 | 14.0 | 8.0 | €226.5M |
| 1 | 1 | 20801 | Cristiano Ronaldo | 33 | https://cdn.sofifa.org/players/4/19/20801.png | Portugal | https://cdn.sofifa.org/flags/38.png | 94 | 94 | Juventus | ... | 95.0 | 28.0 | 31.0 | 23.0 | 7.0 | 11.0 | 15.0 | 14.0 | 11.0 | €127.1M |
| 2 | 2 | 190871 | Neymar Jr | 26 | https://cdn.sofifa.org/players/4/19/190871.png | Brazil | https://cdn.sofifa.org/flags/54.png | 92 | 93 | Paris Saint-Germain | ... | 94.0 | 27.0 | 24.0 | 33.0 | 9.0 | 9.0 | 15.0 | 15.0 | 11.0 | €228.1M |
| 3 | 3 | 193080 | De Gea | 27 | https://cdn.sofifa.org/players/4/19/193080.png | Spain | https://cdn.sofifa.org/flags/45.png | 91 | 93 | Manchester United | ... | 68.0 | 15.0 | 21.0 | 13.0 | 90.0 | 85.0 | 87.0 | 88.0 | 94.0 | €138.6M |
| 4 | 4 | 192985 | K. De Bruyne | 27 | https://cdn.sofifa.org/players/4/19/192985.png | Belgium | https://cdn.sofifa.org/flags/7.png | 91 | 92 | Manchester City | ... | 88.0 | 68.0 | 58.0 | 51.0 | 15.0 | 13.0 | 5.0 | 10.0 | 13.0 | €196.4M |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 18202 | 18202 | 238813 | J. Lundstram | 19 | https://cdn.sofifa.org/players/4/19/238813.png | England | https://cdn.sofifa.org/flags/14.png | 47 | 65 | Crewe Alexandra | ... | 45.0 | 40.0 | 48.0 | 47.0 | 10.0 | 13.0 | 7.0 | 8.0 | 9.0 | €143K |
| 18203 | 18203 | 243165 | N. Christoffersson | 19 | https://cdn.sofifa.org/players/4/19/243165.png | Sweden | https://cdn.sofifa.org/flags/46.png | 47 | 63 | Trelleborgs FF | ... | 42.0 | 22.0 | 15.0 | 19.0 | 10.0 | 9.0 | 9.0 | 5.0 | 12.0 | €113K |
| 18204 | 18204 | 241638 | B. Worman | 16 | https://cdn.sofifa.org/players/4/19/241638.png | England | https://cdn.sofifa.org/flags/14.png | 47 | 67 | Cambridge United | ... | 41.0 | 32.0 | 13.0 | 11.0 | 6.0 | 5.0 | 10.0 | 6.0 | 13.0 | €165K |
| 18205 | 18205 | 246268 | D. Walker-Rice | 17 | https://cdn.sofifa.org/players/4/19/246268.png | England | https://cdn.sofifa.org/flags/14.png | 47 | 66 | Tranmere Rovers | ... | 46.0 | 20.0 | 25.0 | 27.0 | 14.0 | 6.0 | 14.0 | 8.0 | 9.0 | €143K |
| 18206 | 18206 | 246269 | G. Nugent | 16 | https://cdn.sofifa.org/players/4/19/246269.png | England | https://cdn.sofifa.org/flags/14.png | 46 | 66 | Tranmere Rovers | ... | 43.0 | 40.0 | 43.0 | 50.0 | 10.0 | 15.0 | 9.0 | 12.0 | 9.0 | €165K |
18207 rows × 89 columns
fifa19.info()
<class 'pandas.core.frame.DataFrame'> RangeIndex: 18207 entries, 0 to 18206 Data columns (total 89 columns): # Column Non-Null Count Dtype --- ------ -------------- ----- 0 Unnamed: 0 18207 non-null int64 1 ID 18207 non-null int64 2 Name 18207 non-null object 3 Age 18207 non-null int64 4 Photo 18207 non-null object 5 Nationality 18207 non-null object 6 Flag 18207 non-null object 7 Overall 18207 non-null int64 8 Potential 18207 non-null int64 9 Club 17966 non-null object 10 Club Logo 18207 non-null object 11 Value 18207 non-null object 12 Wage 18207 non-null object 13 Special 18207 non-null int64 14 Preferred Foot 18159 non-null object 15 International Reputation 18159 non-null float64 16 Weak Foot 18159 non-null float64 17 Skill Moves 18159 non-null float64 18 Work Rate 18159 non-null object 19 Body Type 18159 non-null object 20 Real Face 18159 non-null object 21 Position 18147 non-null object 22 Jersey Number 18147 non-null float64 23 Joined 16654 non-null object 24 Loaned From 1264 non-null object 25 Contract Valid Until 17918 non-null object 26 Height 18159 non-null object 27 Weight 18159 non-null object 28 LS 16122 non-null object 29 ST 16122 non-null object 30 RS 16122 non-null object 31 LW 16122 non-null object 32 LF 16122 non-null object 33 CF 16122 non-null object 34 RF 16122 non-null object 35 RW 16122 non-null object 36 LAM 16122 non-null object 37 CAM 16122 non-null object 38 RAM 16122 non-null object 39 LM 16122 non-null object 40 LCM 16122 non-null object 41 CM 16122 non-null object 42 RCM 16122 non-null object 43 RM 16122 non-null object 44 LWB 16122 non-null object 45 LDM 16122 non-null object 46 CDM 16122 non-null object 47 RDM 16122 non-null object 48 RWB 16122 non-null object 49 LB 16122 non-null object 50 LCB 16122 non-null object 51 CB 16122 non-null object 52 RCB 16122 non-null object 53 RB 16122 non-null object 54 Crossing 18159 non-null float64 55 Finishing 18159 non-null float64 56 HeadingAccuracy 18159 non-null float64 57 ShortPassing 18159 non-null float64 58 Volleys 18159 non-null float64 59 Dribbling 18159 non-null float64 60 Curve 18159 non-null float64 61 FKAccuracy 18159 non-null float64 62 LongPassing 18159 non-null float64 63 BallControl 18159 non-null float64 64 Acceleration 18159 non-null float64 65 SprintSpeed 18159 non-null float64 66 Agility 18159 non-null float64 67 Reactions 18159 non-null float64 68 Balance 18159 non-null float64 69 ShotPower 18159 non-null float64 70 Jumping 18159 non-null float64 71 Stamina 18159 non-null float64 72 Strength 18159 non-null float64 73 LongShots 18159 non-null float64 74 Aggression 18159 non-null float64 75 Interceptions 18159 non-null float64 76 Positioning 18159 non-null float64 77 Vision 18159 non-null float64 78 Penalties 18159 non-null float64 79 Composure 18159 non-null float64 80 Marking 18159 non-null float64 81 StandingTackle 18159 non-null float64 82 SlidingTackle 18159 non-null float64 83 GKDiving 18159 non-null float64 84 GKHandling 18159 non-null float64 85 GKKicking 18159 non-null float64 86 GKPositioning 18159 non-null float64 87 GKReflexes 18159 non-null float64 88 Release Clause 16643 non-null object dtypes: float64(38), int64(6), object(45) memory usage: 12.4+ MB
fifa19['Body Type'].value_counts()
Normal 10595 Lean 6417 Stocky 1140 Messi 1 C. Ronaldo 1 Neymar 1 Courtois 1 PLAYER_BODY_TYPE_25 1 Shaqiri 1 Akinfenwa 1 Name: Body Type, dtype: int64
f, ax = plt.subplots(figsize=(8,6))
x = fifa19['Age']
ax = sns.distplot(x, bins=10)
plt.show()
f,ax = plt.subplots(figsize=(8,6))
x = fifa19['Age']
x =pd.Series(x , name ='Age variable')
ax =sns.distplot(x,bins=10)
plt.show()
f, ax = plt.subplots(figsize=(8,6))
x =fifa19['Age']
ax = sns.distplot(x,bins=10,vertical = True)
plt.show()
f,ax =plt.subplots(figsize=(8,6))
x = fifa19['Age']
x =pd.Series(x,name='Age varibles')
ax = sns.kdeplot(x)
plt.show()
f,ax = plt.subplots(figsize=(8,6))
x =fifa19['Age']
x = pd.Series(x , name ='Age variable')
ax =sns.kdeplot(x ,shade = True,color = 'g')
f,ax =plt.subplots(figsize=(8,6))
x = fifa19['Age']
ax = sns.distplot(x,kde = False,bins=10,rug =True)
plt.show()
f,ax = plt.subplots(figsize = (8,6))
x = fifa19['Age']
ax =sns.distplot(x,hist = False,bins =10,rug = True)
plt.show()
fifa19.columns
Index(['Unnamed: 0', 'ID', 'Name', 'Age', 'Photo', 'Nationality', 'Flag',
'Overall', 'Potential', 'Club', 'Club Logo', 'Value', 'Wage', 'Special',
'Preferred Foot', 'International Reputation', 'Weak Foot',
'Skill Moves', 'Work Rate', 'Body Type', 'Real Face', 'Position',
'Jersey Number', 'Joined', 'Loaned From', 'Contract Valid Until',
'Height', 'Weight', 'LS', 'ST', 'RS', 'LW', 'LF', 'CF', 'RF', 'RW',
'LAM', 'CAM', 'RAM', 'LM', 'LCM', 'CM', 'RCM', 'RM', 'LWB', 'LDM',
'CDM', 'RDM', 'RWB', 'LB', 'LCB', 'CB', 'RCB', 'RB', 'Crossing',
'Finishing', 'HeadingAccuracy', 'ShortPassing', 'Volleys', 'Dribbling',
'Curve', 'FKAccuracy', 'LongPassing', 'BallControl', 'Acceleration',
'SprintSpeed', 'Agility', 'Reactions', 'Balance', 'ShotPower',
'Jumping', 'Stamina', 'Strength', 'LongShots', 'Aggression',
'Interceptions', 'Positioning', 'Vision', 'Penalties', 'Composure',
'Marking', 'StandingTackle', 'SlidingTackle', 'GKDiving', 'GKHandling',
'GKKicking', 'GKPositioning', 'GKReflexes', 'Release Clause'],
dtype='object')
fifa19['Preferred Foot'].nunique()
2
fifa19['Preferred Foot'].value_counts()
Right 13948 Left 4211 Name: Preferred Foot, dtype: int64
f, ax = plt.subplots(figsize=(8,6))
sns.countplot(x ='Preferred Foot',data = fifa19,color='c')
plt.show()
f, ax = plt.subplots(figsize =(8,6))
sns.countplot(x ='Preferred Foot',hue = 'Real Face',data = fifa19)
plt.show()
f, ax = plt.subplots(figsize=(8,6))
sns.countplot(y = 'Preferred Foot',hue = 'Real Face',data = fifa19)
plt.show()
fifa19.columns
Index(['Unnamed: 0', 'ID', 'Name', 'Age', 'Photo', 'Nationality', 'Flag',
'Overall', 'Potential', 'Club', 'Club Logo', 'Value', 'Wage', 'Special',
'Preferred Foot', 'International Reputation', 'Weak Foot',
'Skill Moves', 'Work Rate', 'Body Type', 'Real Face', 'Position',
'Jersey Number', 'Joined', 'Loaned From', 'Contract Valid Until',
'Height', 'Weight', 'LS', 'ST', 'RS', 'LW', 'LF', 'CF', 'RF', 'RW',
'LAM', 'CAM', 'RAM', 'LM', 'LCM', 'CM', 'RCM', 'RM', 'LWB', 'LDM',
'CDM', 'RDM', 'RWB', 'LB', 'LCB', 'CB', 'RCB', 'RB', 'Crossing',
'Finishing', 'HeadingAccuracy', 'ShortPassing', 'Volleys', 'Dribbling',
'Curve', 'FKAccuracy', 'LongPassing', 'BallControl', 'Acceleration',
'SprintSpeed', 'Agility', 'Reactions', 'Balance', 'ShotPower',
'Jumping', 'Stamina', 'Strength', 'LongShots', 'Aggression',
'Interceptions', 'Positioning', 'Vision', 'Penalties', 'Composure',
'Marking', 'StandingTackle', 'SlidingTackle', 'GKDiving', 'GKHandling',
'GKKicking', 'GKPositioning', 'GKReflexes', 'Release Clause'],
dtype='object')
g = sns.catplot(x = 'Preferred Foot',kind = 'count',palette='ch:25',data=fifa19)
fifa19.columns
Index(['Unnamed: 0', 'ID', 'Name', 'Age', 'Photo', 'Nationality', 'Flag',
'Overall', 'Potential', 'Club', 'Club Logo', 'Value', 'Wage', 'Special',
'Preferred Foot', 'International Reputation', 'Weak Foot',
'Skill Moves', 'Work Rate', 'Body Type', 'Real Face', 'Position',
'Jersey Number', 'Joined', 'Loaned From', 'Contract Valid Until',
'Height', 'Weight', 'LS', 'ST', 'RS', 'LW', 'LF', 'CF', 'RF', 'RW',
'LAM', 'CAM', 'RAM', 'LM', 'LCM', 'CM', 'RCM', 'RM', 'LWB', 'LDM',
'CDM', 'RDM', 'RWB', 'LB', 'LCB', 'CB', 'RCB', 'RB', 'Crossing',
'Finishing', 'HeadingAccuracy', 'ShortPassing', 'Volleys', 'Dribbling',
'Curve', 'FKAccuracy', 'LongPassing', 'BallControl', 'Acceleration',
'SprintSpeed', 'Agility', 'Reactions', 'Balance', 'ShotPower',
'Jumping', 'Stamina', 'Strength', 'LongShots', 'Aggression',
'Interceptions', 'Positioning', 'Vision', 'Penalties', 'Composure',
'Marking', 'StandingTackle', 'SlidingTackle', 'GKDiving', 'GKHandling',
'GKKicking', 'GKPositioning', 'GKReflexes', 'Release Clause'],
dtype='object')
fifa19['International Reputation'].nunique()
5
fifa19['International Reputation'].value_counts()
1.0 16532 2.0 1261 3.0 309 4.0 51 5.0 6 Name: International Reputation, dtype: int64
f,ax = plt.subplots(figsize=(8,6))
sns.stripplot(x = 'International Reputation',y ='Potential',data = fifa19)
plt.show()
f,ax = plt.subplots(figsize = (8,6))
sns.stripplot(x = 'International Reputation',y='Potential',data = fifa19,jitter=0.01)
plt.show()
f,ax = plt.subplots(figsize =(8,6))
sns.stripplot(x ='International Reputation',y='Potential',\
hue='Preferred Foot',data=fifa19,jitter=0.1,palette='Set2',\
dodge = True)
plt.show()
f, ax = plt.subplots(figsize=(8,6))
sns.stripplot(x='International Reputation',y='Potential',\
hue='Preferred Foot',data = fifa19,palette='Set2',size=20,\
marker = 's',edgecolor='gray',alpha=.25)
plt.show()
f, ax = plt.subplots(figsize=(8,6))
sns.boxplot(x=fifa19['Potential'])
plt.show()
f,ax = plt.subplots(figsize=(8,6))
sns.boxplot(x="International Reputation",y='Potential',data=fifa19)
plt.show()
f,ax = plt.subplots(figsize=(8,6))
sns.boxplot(x='International Reputation',y='Potential',hue='Preferred Foot',\
data=fifa19,palette='Set3')
plt.show()
f,ax=plt.subplots(figsize=(8,6))
sns.violinplot(x=fifa19['Potential'])
plt.show()
f,ax = plt.subplots(figsize=(8,6))
sns.violinplot(x="International Reputation",y='Potential',data=fifa19)
plt.show()
f,ax=plt.subplots(figsize=(8,6))
sns.violinplot(x='International Reputation',y='Potential',hue='Preferred Foot',data=fifa19,palette='muted')
plt.show()
f,ax=plt.subplots(figsize=(8,6))
sns.violinplot(x='International Reputation',y='Potential',\
hue='Preferred Foot',data=fifa19,palette='muted',split=True)
<Axes: xlabel='International Reputation', ylabel='Potential'>
f,ax= plt.subplots(figsize=(8,5))
sns.pointplot(x='International Reputation',y ='Potential',data=fifa19)
plt.show()
f,ax=plt.subplots(figsize=(8,6))
sns.pointplot(x='International Reputation',y ='Potential',hue = 'Preferred Foot',\
data = fifa19,dodge=True)
plt.show()
f,ax = plt.subplots(figsize=(8,6))
sns.pointplot(x='International Reputation',y = 'Potential',\
hue = 'Preferred Foot',data=fifa19,markers =['o','x'],\
linestyles=["-","--"])
plt.show()
f,ax = plt.subplots(figsize=(8,6))
sns.barplot(x ='International Reputation',y='Potential',data = fifa19)
plt.show()
f, ax = plt.subplots(figsize=(8,6))
sns.barplot(x ='International Reputation',y='Potential',hue = 'Preferred Foot',\
data = fifa19)
plt.show()
from numpy import median
f,ax = plt.subplots(figsize=(8,6))
sns.barplot(x = 'International Reputation',y = 'Potential',data = fifa19,\
estimator = median) # estimator = median (means we can use the aggregation to determine the height of the bars)
plt.show()
f,ax = plt.subplots(figsize=(8,6))
sns.barplot(x = 'International Reputation',y ='Potential',data = fifa19,\
ci=68)
plt.show()
f, ax = plt.subplots(figsize =(8,6))
sns.barplot(x='International Reputation',y='Potential',data=fifa19,ci='sd')
plt.show()
f,ax=plt.subplots(figsize=(8,6))
sns.barplot(x='International Reputation',y = 'Potential',data = fifa19,\
capsize=1.0)
plt.show()
g = sns.relplot(x='Overall',y='Potential',data=fifa19)
f,ax = plt.subplots(figsize=(8,6))
sns.scatterplot(x='Height',y='Weight',data =fifa19)
plt.show()
f,ax = plt.subplots(figsize=(8,6))
sx = sns.lineplot(x='Stamina',y='Strength',data=fifa19)
plt.show()
f,ax = plt.subplots(figsize=(8,6))
ax = sns.regplot(x='Overall',y = 'Potential',data=fifa19)
plt.show()
f,ax = plt.subplots(figsize=(8,6))
ax=sns.regplot(x='Overall',y='Potential',data=fifa19,color='g',marker='+')
plt.show()
f,ax=plt.subplots(figsize=(8,6))
sns.regplot(x='International Reputation',y ='Potential',data=fifa19,x_jitter=0.01)
plt.show()
g =sns.lmplot(x='Overall',y='Potential',data=fifa19)
g=sns.lmplot(x='Overall',y='Potential',hue='Preferred Foot',data=fifa19)
g=sns.lmplot(x='Overall',y="Potential",hue='Preferred Foot',data=fifa19,palette='Set1')
g=sns.lmplot(x='Overall',y='Potential',col='Preferred Foot',data=fifa19)
g= sns.FacetGrid(fifa19,col='Preferred Foot')
g = sns.FacetGrid(fifa19,col='Preferred Foot')
g = g.map(plt.hist,'Potential')
g = sns.FacetGrid(fifa19,col='Potential')
g=(g.map(plt.hist,'Potential',bins=10,color='r'))
g = sns.FacetGrid(fifa19,col='Preferred Foot')
g = (g.map(plt.scatter,'Height','Weight',edgecolor="w").add_legend())
g = sns.FacetGrid(fifa19,col='Preferred Foot',height =5,aspect =1)
g = g.map(plt.hist,"Potential")
fifa19_new =fifa19[['Age','Potential','Strength','Stamina','Preferred Foot']]
g = sns.PairGrid(fifa19_new)
g = g.map(plt.scatter)
g = sns.PairGrid(fifa19_new)
g = g.map_diag(plt.hist)
g = g.map_offdiag(plt.scatter)
g = sns.PairGrid(fifa19_new,hue= 'Preferred Foot')
g = g.map_diag(plt.hist)
g = g.map_offdiag(plt.scatter)
g = g.add_legend()
g = sns.PairGrid(fifa19_new,hue = 'Preferred Foot')
g=g.map_diag(plt.hist,histtype ='step',linewidth =5)
g=g.map_offdiag(plt.scatter)
g = g.add_legend()
g = sns.PairGrid(fifa19_new,vars=['Age','Stamina'])
g = g.map(plt.scatter)# vars means it will create some rows
g = sns.PairGrid(fifa19_new)
g = g.map_upper(plt.scatter)
g = g.map_lower(sns.kdeplot,cmap = 'Blues_d')
g = g.map_diag(sns.kdeplot,lw=3,legend=False)
g = sns.JointGrid(x='Overall',y = 'Potential',data = fifa19)
g = g.plot(sns.regplot,sns.distplot)
g = sns.JointGrid(x='Overall',y = 'Potential',data=fifa19)
g= g.plot_joint(plt.scatter,color='.5',edgecolor='white') # used to joint unnivariate and bivariate in a single visualization
g = g.plot_marginals(sns.distplot,kde=False,color ='.5')
g = sns.JointGrid(x="Overall",y="Potential",data=fifa19,space=0)
g = g.plot_joint(sns.kdeplot,cmap=('Blues_d'))
g = g.plot_marginals(sns.kdeplot,shade=True)
g = sns.JointGrid(x='Overall',y ="Potential",data=fifa19,height = 5,ratio=2)
g =g.plot_joint(sns.kdeplot,cmap="Reds_d")
g = g.plot_marginals(sns.kdeplot,color="blue",shade=True)
f,ax=plt.subplots(figsize=(8,6))
ax = sns.regplot(x='Overall',y='Potential',data=fifa19);
sns.lmplot(x='Overall',y ="Potential",col='Preferred Foot',data=fifa19,\
col_wrap=2,height=5,aspect =1)
<seaborn.axisgrid.FacetGrid at 0x205ec444350>
def sinplot(flip=1):
x=np.linspace(0,14,100)
for i in range(1,7):
plt.plot(x,np.sin(x+i * .5)*(7-i)*flip)
print(sinplot())
None
sns.set()
sinplot()
sns.set_style("whitegrid")
sinplot()
sns.set_style("dark")
sinplot()
sns.set_style("white")
sinplot()
sns.set_style('ticks')
sinplot()